package com.zyicoding.myfactory.util;

import lombok.Data;

/**
 * 返回Json类型
 */
@Data
public class JsonResult {
    private Integer code;
    private String errorMsg;
    private Object data;

    public JsonResult(Integer code, String errorMsg, Object data) {
        this.code = code;
        this.errorMsg = errorMsg;
        this.data = data;
    }
    public static JsonResult ok() {
        return new JsonResult(200, null, "请求成功");
    }
    public static JsonResult ok(Object data) {
        return new JsonResult(200, null, data);
    }

    public static JsonResult error() {
        return new JsonResult(500, "请求发生错误", null);
    }

    public static JsonResult error(String errorMsg) {
        return new JsonResult(500, errorMsg, null);
    }
}
